package org.zl.mybatis.use.intercept;

import java.sql.PreparedStatement;

import org.apache.ibatis.executor.parameter.ParameterHandler;
import org.apache.ibatis.plugin.Interceptor;
import org.apache.ibatis.plugin.Intercepts;
import org.apache.ibatis.plugin.Invocation;
import org.apache.ibatis.plugin.Signature;

@Intercepts({
	@Signature(type = ParameterHandler.class,
			method = "getParameterObject",
			args = {}),
	@Signature(type = ParameterHandler.class,
			method = "setParameters",
			args = {PreparedStatement.class}),
	
})
public class ParameterHandlerInterceptor implements Interceptor {

	@Override
	public Object intercept(Invocation invocation) throws Throwable {
		System.out.println("\n-------2\n" + invocation);
		System.out.println(invocation.getTarget());
		System.out.println(invocation.getMethod());
		System.out.println(invocation.getArgs() + "\n-------");
		
		Object ret = invocation.proceed();
		return ret;
	}

}
